/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.app.configuration;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.apache.log4j.Logger;
import org.app.utils.PropertiesHelper;

/**
 *
 * @author KM
 */
public class HSQLInit {

    private static Logger logger = Logger.getLogger(HSQLInit.class);
    public static void initDb() {
        Connection connection = null;
        ResultSet resultSet = null;
        Statement statement = null;

        try {
            Class.forName(PropertiesHelper.DB_CONNECTION_CLASS);
            connection = DriverManager.getConnection(PropertiesHelper.DB_CONNECTION_URL, PropertiesHelper.DB_CONNECTION_USERNAME, PropertiesHelper.DB_CONNECTION_PASSWORD);
            statement = connection.createStatement();
            resultSet = statement
                    .executeQuery("SELECT EMPNAME FROM EMPLOYEEDETAILS");
            while (resultSet.next()) {
                logger.info("EMPLOYEE NAME:"
                        + resultSet.getString("EMPNAME"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                resultSet.close();
                statement.close();
                connection.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
